name: Install QA - OS Matrix



on:
  workflow_dispatch:

  push:
    branches:
      - install
    tags:
      - '*'
    paths:
      - 'install/install-snoopy.sh'

  pull_request:
    branches:
      - master
    paths:
      - 'install/install-snoopy.sh'



jobs:
  install-qa-os-matrix:

    name: Install on ${{matrix.container}}
    runs-on: ubuntu-20.04



    ### Define the list of container images
    #
    container: ${{ matrix.container }}
    strategy:
      matrix:
        container:
#FIXME uncomment once Snoopy 2.5.0 containing Alpine-/musl-related fixes is released
#          - alpine:3.14
#          - alpine:3.15
#          - alpine:3.16

          - archlinux:base-devel

          - almalinux/8-base:latest
          - almalinux/9-base:latest

          - quay.io/centos/centos:stream8
          - quay.io/centos/centos:stream9

          - debian:buster
          - debian:bullseye
          - debian:bookworm
          - debian:sid

          - opensuse/leap:15.4
          - opensuse/leap:15.5
          - opensuse/tumbleweed:latest

          - ubuntu:20.04
          - ubuntu:22.04
          - ubuntu:rolling



    ###
    ### Steps to run
    ###
    steps:



      ### Install requirements for the subsequent checkout action
      #

      # Alpine
      - run: apk add bash
        if: ${{ startsWith(matrix.container, 'alpine:') }}

      # SUSE / OpenSUSE
      - run: zypper -n install gzip tar
        if: ${{ startsWith(matrix.container, 'opensuse/') }}



      ### Fetch the code
      #
      - uses: actions/checkout@v2

      # Work around the fix for CVE-2022-24765
      - run: git config --global --add safe.directory $GITHUB_WORKSPACE || true



      ### Install
      #
      - run: ./install/install-snoopy.sh stable



      ### Report debugging info on failure
      #
      - run: cat install-snoopy.log
        if: failure()



      ### Verify Snoopy operation
      #
      - name: Verify Snoopy operation
        run: |
          touch /var/log/snoopy.log
          echo "output = file:/var/log/snoopy.log" >> /etc/snoopy.ini
          /bin/echo "Snoopy is alive and well"
          cat /var/log/snoopy.log | grep -v ': grep' | grep "Snoopy is alive and well"
